<template>
  <a-modal
    title="概念属性"
    :width="modalWidth()"
    :bodyStyle="{'padding-top':0,'min-height':'500px'}"
    :visible="visible"
    :footer="null"
    :centered="true"
    @cancel="handleCancel"
  >
    <property-form :modal="modal" :queryParam="queryParam" ref="propertyForm" @ok="handleOk" />
  </a-modal>
</template>
<script>
import propertyForm from '@/views/main/knowl/property/index'
import { register } from '@/utils/drag_modal'

export default {
  components: {
    propertyForm
  },
  data() {
    return {
      visible: false,
      modal: false,
      queryParam: {}
    }
  },
  methods: {
    modalWidth() {
      return document.body.clientWidth * 0.7
    },
    index(record) {
      this.visible = true
      this.queryParam.schemaId = record.id
      if (this.modal) {
        this.$refs.propertyForm.tableReload()
      }
      this.modal = true
      const viewRight = !!record.showRightTool
      const propertyFrom = this.$refs.propertyForm
      if (propertyFrom) {
        propertyFrom.showRightTool(viewRight)
      } else {
        setTimeout(() => {
          this.$refs.propertyForm.showRightTool(viewRight)
        }, 100)
      }
      register(true)
    },
    handleCancel() {
      register(false)
      this.queryParam = {}
      this.visible = false
    },
    handleOk() {
      this.$refs.propertyForm.table.refresh()
    }
  }
}
</script>
<style>
</style>
